import pywt as wt
import numpy as np


print(wt.families())

for family in wt.families():
    print('%s family:' % family + ','.join(wt.wavelist(family)))

db1 = wt.Wavelet('db1')
print(db1)


def print_array(arr):
    print('[%s]' % ','.join(['%.14f' % x for x in arr]))


print(db1.filter_bank == (db1.dec_lo, db1.dec_hi, db1.rec_lo, db1.rec_hi))  # True
print(db1.dec_len)
print(db1.rec_len)  # 6

x = [3, 7, 1, 1, -2, 5, 4, 6]
cA, cD = wt.dwt(x, 'db2')  # 得到近似值和细节系数
print(cA)  # [5.65685425 7.39923721 0.22414387 3.33677403 7.77817459]
print(cD)  # [-2.44948974 -1.60368225 -4.44140056 -0.41361256  1.22474487]

print(wt.idwt(cA, cD, 'db2'))  # [ 3.  7.  1.  1. -2.  5.  4.  6.]

n = np.eye(4)
print(n)
print(np.shape(n))

nn = np.array([[1, 2], [1, 1], [1, 1]])
print(nn)
print(np.shape(nn))
n1, n2 = np.shape(nn)
print(n1)

spectral_images = np.zeros([2, 3, 2])
print(spectral_images)

nnn = np.array([[[1, 2],[3, 4],[5, 6]]
,[[7, 8]
    ,[9, 10]
    ,[11, 12]]])

a,s,d = np.shape(nnn)
print(nnn)
print(a,s,d)
v = np.zeros([a,s*d])
print(v)
for i in range(a):
    print('===========')
    v[i,:] = np.reshape(nnn[i,:,:],(1,s*d))
    print(v)


# np.save('../out/mad/mad_sampl',nnn)
ns = np.load('../out/mad/mad_sample.npy')
shape = ns.shape
print(shape)

# for i in range(2):
#     print('================')
#     print(nnn[i,:,:])
#
#
# s = np.array([[1,2,3],[4,5,6]])
# print(s)
# b = np.reshape(s,(3,2))
# print(b)


# x = np.empty([3,2],dtype = int)
# print(x)